﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.HA
{
    class Class1
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                da.Value = ppa.Amount;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age==90)
            {
                da.Value = ppa.Amount;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Age < 65)
                {
                    da.Value = ppa.TotalFee + ppa.Amount;
                }
                else
                {
                    double s = ppa.PolicyActing.PeriodActings.Where(p => p.Age >= 65 && p.Period<=ppa.Period).Sum(q => q.DutyActings.First(k => k.Duty.Name == "生存保险").Value);
                    System.Console.WriteLine("累计生存保险"+s);
                    da.Value = ppa.TotalFee + ppa.Amount - s;
                }
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("重大疾病"))
            {

                IPolicyPeriodActing bppa = ppa.SchemePeriodActing.GetBasicPolicyPeriodActing();

                if (bppa != null && bppa.PolicyActing.Policy.Product.Name == "人保_2012版福禄双喜保险_主")
                {
                    bppa.Fee = 0;

                    if (ppa.Period == 0)
                    {
                        da.Value = ppa.TotalFee;
                    }
                    else
                    {
                        da.Value = bppa.Amount;

                    }

                }
                ppa.IsCurrentFinish = true;
            }
        }
    }
}
